<?php
session_start();
global $title;
require_once('db.php');
$title = msg('Search Results');

if (empty($_GET['page'])) $_GET['page'] = 0;
if (empty($_GET['name'])) $_GET['name'] = '';
if (empty($_GET['city'])) $_GET['city'] = '';

if (empty($_REQUEST['name']) && empty($_REQUEST['city'])) list($count, $results) = all_people();
else list($count, $results) = search_person($_REQUEST);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include('header.php') ?>
	<?php include_once("sidebar.php"); ?>
	<div id="content" style="margin-left:20px;">
	
	
	<br><br>
	Welcome to the conversion center for unorganized data about people affected by the earthquake in Haiti. <br><br>
	
	Your job here is to take data from various sources and check to see if the person in the message is in the google people finder. If they're not, please add them with to the google database. 
	<br><br>
	Please read the <a href="http://wiki.ushahidi.com/doku.php?id=people-finder-instructions2">INSTRUCTIONS</a> to get started! Once you have the read instructions, click the number above after 'Messages in queue.' If there are no more messages, then we have completed all the records for now - thanks! If you would like to help out some more, please leave your contact details below.
	<br><br>
    <br><br>
    <div style="padding:15px; background-color:#eee;">
    <?php if(isset($_GET['email'])){ ?>
    
    <b>We got your information and we'll get back to you when there is work to be done. THANKS!!!</b>
    
    <?php }else{ ?>
	
 
    
 
   <br><br><br>
   <form method="post" action="insert_email.php" enctype="multipart/form-data">
    Name: <input  type="text" name="name" maxlength="50" size="30">
    <br>
    Email: <input  type="text" name="email" maxlength="50" size="30">
    <br>
     Phone: <input  type="text" name="phone" maxlength="50" size="30">
    <br>
    Skype: <input  type="text" name="skype" maxlength="50" size="30">
    <br>
     Twitter: <input  type="text" name="twitter" maxlength="50" size="30">
    <br>
    Organization: <input  type="text" name="org" maxlength="50" size="30">
    <br>
     Location: <input  type="text" name="location" maxlength="50" size="30">
   <br><br>
   Languages:
   <br>
   <input type="checkbox" name=english value="1" checked>English<br>
    <input type="checkbox" name=french value="1">French<br>
     <input type="checkbox" name=kreoyl value="1">Kreyol<br>
    
    <br><br>
    What volunteer work have you done with us so far?<br>
    <textarea name="previous_work" cols="40" rows="5">

</textarea>
    
    <br><br>
    
    What volunteer work would you be willing to do?
    <br>
        <textarea name="new_work" cols="40" rows="5">

</textarea>
    <br><br><br>
    
    <input type="submit" value="Submit" />
    </form>
	
    <?php } ?>
    </div>
		<?php
		/*
		<p><?php pmsg('search_intro'); ?></p>
		<?php if (!$results) { ?>
		<?php pmsg('search_nothing_found'); ?>
		<?php } else { ?>
		<p>
			<?php $count = preg_replace("/\,/","",$count); ?>
				<?php pmsg('Showing Results'); ?> <?php print ($_GET['page'] * RESULTS_PER_PAGE) + 1; ?> <?php pmsg('to'); ?> <?php if(isset($_GET['page']))$p=$_GET['page']; else $p=0; print min($count, ($p * RESULTS_PER_PAGE) + RESULTS_PER_PAGE); ?> <?php pmsg('of'); ?> <?php print $count; ?>
		</p>
		
		
			<p id="pager">
				<?php if($count >= RESULTS_PER_PAGE){ ?>
				
					<?php if ($_GET['page'] > 0 ){ ?>
						<a href="/search_post.php?page=<?php print $_GET['page'] - 1; ?>&city=<?php print $_GET['city']; ?>&name=<?php print $_GET['name'];?>">&laquo;Previous</a>
					<?php } ?>
					&nbsp;
					<?php if ($_GET['page'] * RESULTS_PER_PAGE < $count - RESULTS_PER_PAGE){ ?>
						<a href="/search_post.php?page=<?php print $_GET['page'] + 1; ?>&city=<?php print $_GET['city']; ?>&name=<?php print $_GET['name'];?>">Next &raquo;</a>
					<?php } ?>
				<?php } ?>
			</p>
			
			
			
		<table class="data-table">
			<thead>
				<th>*</th>
				<th>Full Name</th>
				<th>Address</th>
				<th>City</th>
				<th>Department</th>
				<th>Lat/Lon</th>
				<th>Status</th>
				<th>SMS</th>
				<th>Categorization</th>
				<th>Notes</th>
			</thead>
			<tbody>
			<?php
				$row_count = -1;
				while ($row = mysql_fetch_assoc($results)) {
					$row_count++;
					$row = array_map('stripslashes', $row);
					$row_class = ($row_count % 2) ? 'odd' : 'even';
			?>
			<tr class="<?php echo $row_class; ?>">
				<td><?php //if($_SESSION['authenticated'] == 'PCY492My6U8arf') { ?><a href="/person.php?id=<?php echo $row['id']; ?>">Edit</a><?php }
				?></td>
				<td><?php echo $row['fullname'];?></td>
				<td><?php echo $row['address'];?></td>
				<td><?php echo $row['city'];?></td>
				<td><?php echo $row['department'];?></td>
				<td><?php echo $row['lat'].','.$row['lon']; ?></td>
				<td><?php echo $row['status'];?></td>
				<td><?php echo $row['sms'];?></td>
				<td><?php echo $row['aid_type'];?></td>
				<td><?php echo $row['notes'];?></td>
			</tr>
			<?php } ?>
			<tr><td colspan="5">
			<p id="pager">
			<?php $count = preg_replace("/\,/","",$count); ?>
				<?php if($count >= RESULTS_PER_PAGE){ ?>
				
					<?php if ($_GET['page'] > 0 ){ ?>
						<a href="/search_post.php?page=<?php print $_GET['page'] - 1; ?>&city=<?php print $_GET['city']; ?>&name=<?php print $_GET['name'];?>">&laquo;Previous</a>
					<?php } ?>
					&nbsp;
					<?php if ($_GET['page'] * RESULTS_PER_PAGE < $count - RESULTS_PER_PAGE){ ?>
						<a href="/search_post.php?page=<?php print $_GET['page'] + 1; ?>&city=<?php print $_GET['city']; ?>&name=<?php print $_GET['name'];?>">Next &raquo;</a>
					<?php } ?>
				<?php } ?>
			</p>
			</td></tr>
			</tbody>
		</table>
		<?php } ?>
		<?php */ ?>
	</div>
</div>
<?php require_once('footer.php'); ?>
</body>
</html>
